$(->
    $("#subtag").click((e) ->
        if $("input[name='illustTags']").val() == ""
            e.preventDefault()
        )
    $(".itemimg").click( ->
        # console.log $(@).parent()
        itemimg = $("#itemimg")
        if itemimg.hasClass("span9")
            itemimg.removeClass("span9").addClass("span12")
            itemimg.next().removeClass("span3").addClass("span12")

        else 
            itemimg.removeClass("span12").addClass("span9")
            itemimg.next().removeClass("span12").addClass("span3")
            # itemimg
            # itemimg
        )
    taglen = otags.length
    # 验证标签是否已存在
    $(".tm-input").tagsManager (
        hiddenTagListName: 'illustTags'
        validator: (data) ->
            i = 0
            while i < taglen
                if otags[i] is data
                    return false
                i++
            return true
        )
    )
angular.module("itemApp", ['commonApp'])
.run(["$rootScope", ($rootScope) ->
    $rootScope.target = "_self"
    ])
.controller("tagCtrl", ["$scope", "$rootScope","togFullScreen", ($scope, $rootScope, togFullScreen) ->
    $scope.full = togFullScreen
    # 判断是否有标签存在 如果没有则隐藏标签框
    $scope.taglist = otags
    if $.trim(otags) == ""
        $scope.tagst = true
    ])
.controller("illustIntro", ["$scope", "$http", ($scope, $http) ->
    $scope.sendIntro = (oldintro)->
        # console.log $scope.intro,$("input[name='pid']").val()
        intro = $scope.intro
        if $.trim(intro) == '' || oldintro == intro
            return
        $http.post "/illust/upintro", 
                    "intro" : $scope.intro
                    "id": $("input[name='pid']").val()
                .success (data) ->
                    # console.log(data)
    ])
